package com.itheima.dao.impl;

import com.itheima.dao.AccountDao;
import org.apache.commons.dbutils.QueryRunner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

/**
 * <bean id="accountDao" class="com.itheima.dao.impl.AccountDaoImpl">
 *     <property name="queryRunner" ref="queryRunner"></property>
 * </bean>
 */
@Repository
public class AccountDaoImpl implements AccountDao {

    //NullPointerException ->   null.方法了
    //成员变量
    @Autowired
    private QueryRunner queryRunner;

    @Override
    public void save() throws SQLException {
        System.out.println("dao 代码执行了");

        String sql = " insert into tbl_account values(?,?,?)";
        Object [] params = {
                null , "张胖子", 1000
        };
        //操作    null.方法了
        int count = queryRunner.update(sql, params);
        System.out.println(count);
    }
}
